﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="MicroBus"
    targetNamespace="urn:schemas-kli-dk:microbus-configuration"
    elementFormDefault="qualified"
    xmlns="urn:schemas-kli-dk:microbus-configuration"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
>

  <xs:complexType name="Sender">
    <xs:annotation>
      <xs:documentation>
        Immediately publishes a message to a WCF endpoint.
      </xs:documentation>
    </xs:annotation>
    <xs:attribute name="name"/>
  </xs:complexType>

  <xs:complexType name="QueuedSender">
    <xs:annotation>
      <xs:documentation>
        Queues a message in MSMQ until it can be successfully published to a WCF endpoint.
      </xs:documentation>
    </xs:annotation>
    <xs:complexContent>
      <xs:extension base="Sender"/>
    </xs:complexContent>
  </xs:complexType>

  <xs:group name="Senders">
    <xs:choice>
      <xs:element name="Sender" type="Sender"/>
      <xs:element name="QueuedSender" type="QueuedSender"/>
    </xs:choice>
  </xs:group>

  <xs:complexType name="Filter">
    <xs:annotation>
      <xs:documentation>
        Filters messages on topic by wildcard.
      </xs:documentation>
    </xs:annotation>
    <xs:group ref="Senders" minOccurs="1" maxOccurs="unbounded"/>
    <xs:attribute name="topic"/>
  </xs:complexType>

  <xs:complexType name="Receiver">
    <xs:annotation>
      <xs:documentation>
        Subscribes to messages using a WCF service.
      </xs:documentation>
    </xs:annotation>
    <xs:choice minOccurs="1" maxOccurs="unbounded">
      <xs:group ref="Senders" />
      <xs:element name="Filter" type="Filter"/>
    </xs:choice>
    <xs:attribute name="name"/>
  </xs:complexType>

  <xs:element name="MicroBus">
    <xs:annotation>
      <xs:documentation>
        Specifies the root element that contains the endpoints that receive messages.
      </xs:documentation>
    </xs:annotation>
    <xs:complexType>
      <xs:sequence minOccurs="0" maxOccurs="unbounded">
        <xs:element name="Receiver" type="Receiver" />
      </xs:sequence>
    </xs:complexType>
  </xs:element>
  
</xs:schema>
